<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>System</title>
<script type="text/javascript">
 	var  LANG={$JSLANG};
</script>
{include file='header.tpl' JS=$smarty.const.BAOGG_JS CSS=$smarty.const.BAOGG_CSS}  
<style type="text/css">
{foreach $menu_clses as $k_menu_cls=>$v_menu_cls}
	.{$k_menu_cls} {
		background-image:url({$v_menu_cls});
	}

{/foreach}
</style>
</head>
 
<body>
<div id="center_panel"> 
	<div  style="margin-top:20%;margin-left:50%;font-size:23px;" >
        CMH数据查询系统
	</div>
        <!--
	<div style="position:absolute;bottom:15px;margin-left:50%;">
		@All rights reserved, powered by beimuaihui
	</div>
        -->
</div>

</body>

</html>
<script type="text/javascript"><!--
	
	Ext.define('Menu', {
		    extend: 'Ext.data.Model',
		    fields: ['id', 'url', 'icon','text','itemId']});
	


	var addTab,addTab2,addTabByMenu;
	var currentItem=null;

            (function(){
                index = 0;              
                
                addTab=function(item){
                	if(cenbterTabPanel.getComponent('tab_tb'+item.id)){						
                		//cenbterTabPanel.activate('tb'+item.id);
                		cenbterTabPanel.setActiveTab(cenbterTabPanel.getComponent('tab_tb'+item.id));						
               			 Ext.getCmp('panel_' + item.id).el.dom.src=item.url;  //refresh page
				 //console.info( cenbterTabPanel.getActiveTab().items.first().el.dom);
				 //cenbterTabPanel.getActiveTab().items.first().el.dom.contentWindow.location.reload();
				 //Ext.getCmp('panel_' + item.id).el.dom.contentWindow.location.reload(true);
                	}else{
                		
						
	                    cenbterTabPanel.add({
		                    
	                    	id:'tab_tb'+item.id,
	                        title:item.text,
	                        iconCls: 'baogg-tb'+item.id,
				//icon: item.icon,
				frame: true,
	                        layout: 'fit',
	                        items: [{
								xtype : "component",
								id: 'panel_' + item.id,
								closable: true,
								border:0,
								autoEl : {
									tag : "iframe",
									src : item.url,
									frameBorder:"0",
									border:'none'
								}
	                        }],						    
	                        closable: true
	                    }).show();
	                 }
                };

               addTab2=function(item){
					
                	if(cenbterTabPanel.getComponent('tab_'+item.id)){
                		cenbterTabPanel.setActiveTab(cenbterTabPanel.getComponent('tab_'+item.id));
                		//console.info(item.href);
                		//console.info(Ext.getCmp('panel_' + item.id).el.dom);
						 Ext.getCmp('panel_' + item.id).el.dom.src=item.href;  //refresh page
						//cenbterTabPanel.getActiveTab().el.dom.contentWindow.location.reload();
               			  
						//Ext.getCmp('panel_' + item.id).el.dom.contentWindow.location.reload(true);
                	}else{
                		
	                    cenbterTabPanel.add({
		                    
	                    	id:'tab_'+item.id,
	                        title:item.innerHTML,
	                        iconCls: 'baogg-'+item.id,
				//itemCls:'x-btn-text-icon',
				//cls:'x-btn-text-icon',
				//icon: item.parentNode.firstChild.src,
	                        frame: true,
	                        layout: 'fit',
	                        items: [{
								border:false,
								xtype : "component",
								id: 'panel_' + item.id,
								closable: true,
								autoEl : {
									tag : "iframe",
									src : item.href,
									frameBorder:"0",
									border:'none'
								}
							}],
	                        closable: true
	                    }).show();
	                 }
                };
			addTabByMenu=function(menu){
				menu.id='menu_'+menu.menu_id;
				menu.icon=menu.img_icon;
				menu.text=menu.menu_name;
				addTab(menu);
			};
              
                
                
                //center tabpanel
                
               
               
               var cenbterTabPanel = Ext.create('Ext.tab.Panel',{
                	 tbar: ['->', {
                		 "xtype":"combo",
                		 "id":"qa_surveys_id",                         
                         "submitValue":false,
                         "displayField":"text",
                         "valueField":"id",			
                         "store":Ext.create('Ext.data.ArrayStore', { model:'ComboModel',data:{$store_surveys} } ),
                         "value":{$init_surveys},
				  		 "triggerAction":"all",				  		 				
						 "forceSelection":true,
						 "hideTrigger":false,
						 "listeners" :{							  
							  "select":function(self,record,opt){								  
								  //console.info(record);
								 // console.info(record[0].get("id"));
								  
								  window.location.href="{$smarty.const.BAOGG_BASE_URL}?surveys="+record[0].get("id");
							  }
						 }
						 },'|',{
          				text : '{$exit}'
          				   ,handler : function(o){ window.location.href='{$smarty.const.BAOGG_BASE_URL}system/user/login'; }
          				}],
                    region: 'center',
                    activeTab: 0,
                    id:'centerPanel',
                    tabPosition: 'bottom',
		    plugins: Ext.create('Ext.ux.TabCloseMenu', {
		            extraItemsTail: [
		              '-',{ text:LANG.refresh,hideOnClick:true,handler:function(item){ 
                                        currentItem.child().el.dom.src=currentItem.child().el.dom.src;
                                }
                        },  '-',
                	{
	                    text: LANG.closable,
        	            checked: true,
                	    hideOnClick: true,
	                    handler: function (item) {
                     		   currentItem.tab.setClosable(item.checked);
	                    }
        	        }
	            ],
	            listeners: {
	                aftermenu: function () {
        	            currentItem = null;
                	},
	                beforemenu: function (menu, item) {
        	            var menuitem = menu.child('*[text="'+LANG.closable+'"]');
                	    currentItem = item;
	                    menuitem.setChecked(item.closable);
        	        }
	            }
	        }),
				
						
                    items: [{
                        title: '控制面板',
                        html: '',
                        contentEl: 'center_panel'
                    }]
                });
                 
              
                Ext.onReady(function(){
              	 	 var viewport = Ext.create('Ext.container.Viewport', {
                        layout:'border',      
                        autoShow:true,
			renderTo: Ext.getBody(),
                        listeners: {
				show :function(self,opt){	
                                {foreach $parent_menu_ids as $parent_menu_id}
                                        Ext.getCmp('panel_{$parent_menu_id}').doComponentLayout();
                                        {/foreach}
					
                                }
			},

                        items: [{$accordion},cenbterTabPanel]
                    });
		
		    Ext.getCmp("action-panel").body.on("click",function(evt,el){ addTab2(el); },null,{ delegate:'a',stopEvent : true }); 

		    //fixed ie7 panel hidden bug
                    if(Ext.isIE7 ){
                        {foreach $parent_menu_ids as $parent_menu_id}
                                Ext.getCmp('panel_{$parent_menu_id}').doComponentLayout();
                        {/foreach}
                    }
                });
            })()
        --></script>

